package ua.khpi.si.kit49.diploma.db.dao;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import ua.khpi.si.kit49.diploma.db.dto.RoadPriority;

/**
 * Implementation of RoadPriorityDAO
 * 
 * @author netstalk3r
 * 
 */

@Repository("roadPriorityDAO")
public class RoadPriorityDAOImpl implements RoadPriorityDAO {

	private static final String QUERY_GET_ROAD_PRIORITY_BY_ID = "FROM RoadPriority WHERE id = :id";

	@Autowired(required = true)
	private SessionFactory sessionFactory;

	@Override
	public RoadPriority getRoadPriorityById(Integer id) {
		return (RoadPriority) sessionFactory.getCurrentSession()
				.createQuery(QUERY_GET_ROAD_PRIORITY_BY_ID)
				.setParameter("id", id).uniqueResult();
	}

}
